package ch.fusun.baron.core.service;

import java.util.Collection;

import ch.fusun.baron.core.rmi.User;
import ch.fusun.baron.data.DataProvider;

/**
 * Interface for services that manage users
 */
public interface UserService extends DataProvider {

	/**
	 * Creates a new user
	 * 
	 * @param user
	 *            The new user
	 */
	void createUser(User user);

	/**
	 * @param user
	 *            The user
	 * @param id
	 *            The id
	 */
	void login(User user, int id);

	/**
	 * Logs out the user with the specified id
	 * 
	 * @param id
	 *            the id of the user
	 */
	void logout(int id);

	/**
	 * Checks if the username is already taken
	 * 
	 * @param name
	 * @return true iff the username is free
	 */
	boolean exists(String name);

	/**
	 * @param user
	 *            The user to be checked
	 * @return true iff the user is logged in
	 */
	boolean isLoggedIn(User user);

	/**
	 * @return all registered users
	 */
	Collection<User> getUsers();

	/**
	 * @return The current user
	 */
	User getUser();

	/**
	 * @param user
	 *            The user
	 */
	void setUser(User user);

}
